<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <title>师兄帮忙-发布页面</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
<style>
    body, p, ul, li, div,h4 {
        margin: 0;
        padding: 0;
    }
    body {
        font: 14px "SimHei";
        background:#eee;
    }
    a {
        color: #FFF;
        text-decoration: none;
    }
    ul, ol {
        list-style: none;
    }
    img, input {
        border: none;
    }
    .nav-box {
        margin: 0 10px;
    }
    .content li p {
      height: 1.5em;
      line-height: 1.5em;
    }
    .content li input {
      width: 100%;
      border-radius: 8px;
      border: 1px solid #ccc;
      height: 2.5em;
      line-height: 2.5em;
      text-indent: 10px;
      font-size: 1em;
      margin-bottom: 5px;
    }
    .content li textarea{
      width: 100%;
      border-radius: 8px;
      font-size: 1em;
      text-indent: 10px;
    }
    .content li .sub {
      background: #fbfbfb;
      display: block;
      border-radius: 8px;
      border: 1px solid #ccc;
      color: #444;
      height: 2.5em;
      line-height: 2.5em;
      text-align: center;
    }
    #mask {
      width: 100%;
      height: 100%;
      position: fixed;
      background: #ccc;
      z-index: 1;
      display: none;
      opacity: .4;
    }
    #tips {
      width: 80%;
      position: fixed;
      top: 50%;
      left: 50%;
      z-index: 5;
      display: none;
      margin-left: -40%;
      background: #fff;
      border-radius: 8px;
      border: 1px solid  #ccc;
    }
    #tips p {
      font-size: 1.4em;
      margin: 10px;
    }
    #tips span {
      display: block;
      border: 1px solid #ccc;
      margin: 5px auto;
      width: 80px;
      text-align: center;
      height: 2em;
      line-height: 2em;
    }
    #content span {
      display: none;
      color: red;
    }
</style>
<script src="__PUBLIC__/Style/Common/js/zepto.min.admin.js"></script>
<script src="__PUBLIC__/Style/Common/js/GH.1.1.js"></script>
<script type="text/javascript">
  window.onload=function(){
    var oNamekey=document.getElementById('namekey'),
      oSub=document.getElementById('sub'),
        oContkey=document.getElementById('contentkey'),
        oSidkey=document.getElementById('sidkey'),
          oJudge=true,
              re=/<[^<>]+>/g;
   oSub.onclick=function(){   
      if(verify()==true){
          var url="__URL__/add";       
            GH.ajax(url, {name:oNamekey.value, content : oContkey.value,sid:oSidkey.value}, function (arr) { 
            GH.showMessage(arr.msg);
            setTimeout(function(){window.location="http://5.wmei.sinaapp.com/index.php/Home/BrotherHelp";},1500)
          });
      }
   }
   
   function showList( data, append ) {
          if ( !data ) {  // 没有数据的情况
            if ( append ) {
              GH.showMessage( "已经没有数据了" );
              --page;
              pullRefresh();
            } else {
              GH.showMessage( "抱歉，这里没什么东西" );
              GH.$( "#list" ).innerHTML = "<div class='news-item container'><p class='tc'>没有数据</p></div>";
            };
            hideLoading();
            return false;
          };
          
    }

    $('#tips span').click(function(){
      $('#tips').hide();
      $('#mask').hide();
    })
    function verify(){
      oJudge=true;
        if($( '#namekey' ).val()==''||$('#content li span').eq(0).css('display')!='none'||$( '#namekey' ).val().match(re)!=null){
            GH.showMessage('你输入的昵称不符合规范');
            return false;
        }
        if($( '#contentkey' ).val()==''||$('#content li span').eq(1).css('display')!='none'||$( '#contentkey' ).val().match(re)!=null){
            GH.showMessage('你输入的内容不符合规范');
            return false;
        }
        return oJudge;
    }
    oNamekey.onblur=function(){
     judge('12','2','0',oNamekey);
    }
    oContkey.onblur=function(){
      judge('500','7','1',oContkey)
    }
    function judge(obj,obj2,num,othis){
      if(othis.value.length>obj||othis.value.length<obj2){
         $('#content span').eq(num).show();
       }else{
         $('#content span').eq(num).hide();
       };
    }
  }
</script>
</head>
<body>

  <div class="nav-box">
    <form  method="post" id="forms">
      <ul class="content" id="content">
        <li>
          <p>昵称</p>
          <input type="text" id="namekey" name="name"   placeholder="请输入2-14个字符作为您的昵称">
          <span>字数限制2-14个字符</span>
        </li>
        <li>
          <p>输入内容</p>
          <textarea id="contentkey" rows="4"  name="content" placeholder="请输入7-500个字符"></textarea>
          <span>字数限制7-500个字符</span>
        </li>
        <li>
        <input type="hidden" name="sid" id="sidkey" value="{$sid}" />
          <div class="h"></div>
          <a href="javascript:;" class="sub" id="sub">提交</a>
        </li>
      </ul>
    </form>
  </div>
</body>
</html>